#!/usr/bin/bash

#准备环境
chmod a+x ./*.sh
sh ./sourceChg.sh

#安装环境依赖
sudo apt-get update

echo "安装go  =============="
wget https://dl.google.com/go/go1.13.8.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.13.8.linux-amd64.tar.gz
rm go1.13.8.linux-amd64.tar.gz
echo 'export PATH="$PATH:/usr/local/go/bin"' >> ~/.bashrc

echo "安装其他  =============="
sudo apt-get install -y python-software-properties
sudo apt-get install -y software-properties-common
echo "安装其他 完成  =============="
echo "安装gcc  =============="
sudo apt-get install -y gcc-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 50   
#sudo update-alternatives --config gcc					# 这里弹出版本，选择gcc8
echo "安装gcc 完成  =============="

echo "安装git  =============="
sudo apt-get install -y git 
echo "安装git 完成  =============="

echo "安装bzr  =============="
sudo apt-get install -y bzr
echo "安装bzr 完成  =============="
echo "安装jq  =============="
sudo apt-get install -y jq
echo "安装jq 完成 =============="
echo "安装pkg-config  =============="
sudo apt-get install -y pkg-config
echo "安装pkg-config 完成 =============="

echo "更新apt-get  =============="
sudo apt-get update
echo "更新apt-get 完成  =============="

#sudo apt-get install -y opencl-icd-loader  	# no
#sudo apt-get install -y opencldriver 		# no
echo "安装opencl-headers  =============="
sudo apt-get install -y opencl-headers 
echo "安装opencl-headers 完成  =============="
#sudo apt-get install -y rustup  				# no
echo "安装llvm  =============="
sudo apt-get install -y llvm 
echo "安装llvm 完成  =============="
echo "安装libclang-dev  =============="
sudo apt-get install -y libclang-dev
echo "安装libclang-dev 完成  =============="
echo "安装clang  =============="
sudo apt-get install -y clang 
echo "安装clang 完成  =============="

echo "安装mesa-opencl-icd  =============="
sudo apt-get install -y mesa-opencl-icd ocl-icd-opencl-dev
echo "安装mesa-opencl-icd 完成   =============="
echo "安装ocl-icd-opencl-dev  =============="
sudo apt-get install -y ocl-icd-opencl-dev
echo "安装ocl-icd-opencl-dev 完成  =============="
echo "安装curl  =============="
sudo apt-get install -y curl
echo "安装curl 完成  =============="
echo "安装clinfo  =============="
sudo apt-get install -y clinfo
echo "安装clinfo 完成  =============="
echo "安装beignet  =============="
sudo apt-get install -y beignet
echo "安装beignet 完成 =============="

echo "下载 https://sh.rustup.rs  =============="
curl https://sh.rustup.rs -sSf | sh
echo "下载 https://sh.rustup.rs 完成 =============="
echo "安装rustc =============="
sudo apt-get install -y rustc
echo "安装rustc 完成 =============="
echo "安装cargo =============="
sudo apt-get install -y cargo
echo "安装cargo 完成 =============="

echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc

echo "git clone clone https://gitee.com/gitee_jz/lotus.git ~/lotus=============="
git clone https://gitee.com/skycto/lotus.git ~/lotus
echo "git clone clone https://gitee.com/skycto/lotus.git ~/lotus 完成 =============="
#设置环境
echo "设置环境 =============="
sh ./lotus-env-install.sh